package designparttern;

public class SingletonPattern {
    private static volatile SingletonPattern singleton;
    private SingletonPattern(){}
    //恶汉式


    //懒汉式

    //双重检查
    public static SingletonPattern getInstance() {
        if (singleton == null) {
            synchronized (SingletonPattern.class) {
                if (singleton == null) {
                    singleton = new SingletonPattern();
                }
            }
        }
        return singleton;
    }

    //延迟初始化
}
